package controle;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import comando.ComandoEfetuaLogin;
import comando.ComandoExibeLogin;
import javax.servlet.ServletConfig;
import modelo.Inicializador;

public class ServletLogin extends HttpServlet {
	
	private static final long serialVersionUID = -2042852408054008832L;
	
	private ComandoExibeLogin comandoExibeLogin = new ComandoExibeLogin();
  	private ComandoEfetuaLogin comandoEfetuaLogin = new ComandoEfetuaLogin();
	

        @Override
        public void service( HttpServletRequest request, HttpServletResponse response)
	    throws ServletException, IOException       
	{
		String proxima = null;
		
		String cmd = request.getParameter("cmd");
		
		if (cmd.equals("exibeLogin")) 
                     
			proxima = comandoExibeLogin.executar();
		else if (cmd.equals("efetuaLogin"))
			proxima = comandoEfetuaLogin.executar(request);
		
		RequestDispatcher rd;
  		rd = request.getRequestDispatcher(proxima);
  		rd.forward(request, response);
		
		
	}
}
